package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 朋友圈
 */
@Getter
@Setter
public class FriendNews extends BaseDomain implements Comparable<FriendNews>{

    
    public static final Integer VIEW_RANGE_FRIEDN=1;  //指定某些朋友可见
    public static final Integer VIEW_RANGE_ALL=0;  //全部好友可见
    public static final Integer VIEW_RANGE_ME=-1;    //仅自己可见
    //动态发布人
    private User friend;
    //动态内容
    private String content;
    //是否发布
    private Boolean isRelease=true;
    //状态
    private Integer status=VIEW_RANGE_ALL;
    //发布时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date releaseTime;
    //动态图片
    private String pics;
    //动态图片回显
    private List picsForHtml;
    //点赞信息回显
    private List<Map> liker;
    //回复信息回显
    private List<Map> replies;

    @Override
    public int compareTo(FriendNews o) {
        if (o.getReleaseTime() != null) {
            if (DateUtil.after(this.getReleaseTime(), o.getReleaseTime())) {
                return 1;
            } else if (DateUtil.after(o.getReleaseTime(), this.getReleaseTime())) {
                return -1;
            }
        }
        return 0;

    }
}
